package com.jin290.mqlibrary;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/14.
 */

public class MQHome {
    //点击事件
    public static OnMQprocessListener listener;
    private static String Title;
    private static String Colour;

   static  String course1 = "语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文,语文," +
            "数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学,数学";

    static String week1 = "--:--,06:00~06:05,13:00~13:05,22:00~22:05,17:00~17:05,12:00~12:05,00:00~00:00,00:00~00:00";

    private MQHome() {
    }

    public static MQHome InitSDK() {
        return getMQhemo.initMQHome;
    }

    private static class getMQhemo {
        static final MQHome initMQHome = new MQHome();
    }


    public interface  OnMQprocessListener{
        public void MQprocess(List<String> courseList,List<String> weekList);
    }


    /***
     *
     * @param context
     * @param course 课程表数据
     * @param week   时间数据
     * @param onMQprocessListener
     */
    public static void StartCourse(Activity context, List<String> course, List<String> week ,OnMQprocessListener onMQprocessListener)
    {
        listener=onMQprocessListener;
        Intent intent = new Intent(context, CourseActivity.class);
        intent.putStringArrayListExtra("course", (ArrayList<String>) course);
        intent.putStringArrayListExtra("week", (ArrayList<String>) week);
        context.startActivity(intent);
    }


    //关闭回调数据
    public void setBack(List<String> courseList,List<String> weekList)
    {
        MQHome.InitSDK().listener.MQprocess(courseList,weekList);
    }


    //设置课程表标题
    public static void setTitle(String title)
    {
         Title=title;
    }
    public static String getTitle()
    {

        if(!TextUtils.isEmpty(Title))
        {
            return  Title;
        }
        else
        {
            return "";
        }
    }

    public static void setColour(String colour)
    {
        Colour=colour;
    }

    public static String getColour()
    {

        if(!TextUtils.isEmpty(Colour))
        {
            return  Colour;
        }
        else
        {
            return "";
        }

    }


    public static List<String> getcourse()
    {

        List<String> course = new ArrayList<>();

        //String 转List
        String[] ary = course1.split(",");
        for (String ss : ary) {
            course.add(ss);
        }

        return course;

    }

    public static List<String> getweek()
    {

        List<String> week = new ArrayList<>();

        //String 转List
        String[] ary = week1.split(",");
        for (String ss : ary) {
            week.add(ss);
        }

        return week;

    }



}
